import { ColumnGroupType, ColumnType } from "antd/es/table"

import { handleNumber } from "@/utils/util"

const ProxyRebateDetailColumns = (
	newFormat: (arg: string) => string,
	getFromDic: (arg: string, strictlyLabel?: boolean) => any
): Record<string, ColumnGroupType<any> | ColumnType<any>> => {
	const bounsPayoutStatusMap: { [key: string]: string } = {
		"0": "待发放",
		"1": "待发放",
		"2": "待发放",
		"3": "已发放",
		"4": "已过期",
		"5": "无返水",
		"6": "已取消"
	}

	return {
		proxyRebateDetail_userName: {
			title: newFormat("funds.proxy_name"),
			dataIndex: "userName",
			key: "userName",
			align: "center",
			render: (text: any) => text || "-"
		},
		proxyRebateDetail_parentProxyName: {
			title: newFormat("funds.fund_audit.parent_proxy_account"),
			dataIndex: "parentProxyName",
			key: "parentProxyName",
			align: "center",
			render: (text: any) => text || "-"
		},
		proxyRebateDetail_merchantName: {
			title: newFormat("common.belong_merchant"),
			dataIndex: "merchantName",
			key: "merchantName",
			align: "center",
			render: (text: any) => text || ""
		},
		proxyRebateDetail_accountStatus: {
			title: newFormat("common.account_status"),
			dataIndex: "accountStatus",
			key: "accountStatus",
			align: "center",
			render: (text: any, record: any) => (
				<>
					{record.loginLockStatus === 1 && <span className="disableRgba">{newFormat("common.login_lock_status")}</span>}
					{record.paymentLockStatus === 1 && <span className="deleteRgba">{newFormat("common.account_lock_status")}</span>}
					{record.loginLockStatus === 0 && record.paymentLockStatus === 0 && (
						<span className="normalRgba">{newFormat("common.account_status_normal")}</span>
					)}
				</>
			)
		},
		proxyRebateDetail_createdAt: {
			title: newFormat("funds.fund_audit.register_time"),
			dataIndex: "createdAt",
			key: "createdAt",
			align: "center",
			render: (text: any) => text || "-"
		},

		//table 2
		proxyRebateDetail_payoutStatus: {
			title: newFormat("funds.fund_audit.rebate_state"),
			dataIndex: "payoutStatus",
			key: "payoutStatus",
			align: "center",
			render: getFromDic("proxyPayoutStatus", false)
		},
		proxyRebateDetail_personRebateAmount: {
			title: newFormat("funds.proxy_member_funds_record.person_rebate_amount"),
			dataIndex: "personRebateAmount",
			key: "personRebateAmount",
			align: "center",
			render: (text: any, record: any) => handleNumber(record.currency, text)
		},
		proxyRebateDetail_childRebateAmount: {
			title: newFormat("funds.proxy_member_funds_record.child_rebate_amount"),
			dataIndex: "childRebateAmount",
			key: "childRebateAmount",
			align: "center",
			render: (text: any, record: any) => handleNumber(record.currency, text)
		},
		proxyRebateDetail_rebateAmount: {
			title: newFormat("funds.proxy_member_funds_record.rebate_amount_point"),
			dataIndex: "rebateAmount",
			key: "rebateAmount",
			align: "center",
			render: (text: any, record: any) => handleNumber(record.currency, text)
		},
		// table 3
		proxyRebateDetail_memberNumber: {
			title: newFormat("common.member_number"),
			dataIndex: "userName",
			key: "userName",
			align: "center",
			render: (text: string) => text || "-"
		},
		proxyRebateDetail_belongProxy: {
			title: newFormat("funds.fund_audit.belong_proxy"),
			dataIndex: "parentProxyName",
			key: "parentProxyName",
			align: "center",
			render: (text: string) => text || "-"
		},
		proxyRebateDetail_accountStatus1: {
			title: newFormat("common.account_status"),
			dataIndex: "accountStatus",
			key: "accountStatus",
			align: "center",
			render: (text: any, record: any) => (
				<>
					{!!record.paymentLockStatus && (
						<span className="deleteRgba">
							{newFormat("common.account_lock_status")}
							<br />
						</span>
					)}
					{!!record.loginLockStatus && (
						<span className="disableRgba">
							{newFormat("common.login_lock_status")}
							<br />
						</span>
					)}
					{!!record.gameLockStatus && <span className="lockingRgba">{newFormat("common.game_lock_status")}</span>}
					{record.loginLockStatus === 0 && record.gameLockStatus === 0 && record.paymentLockStatus === 0 && (
						<span className="normalRgba">{newFormat("common.account_status_normal")}</span>
					)}
				</>
			)
		},
		proxyRebateDetail_registerTime: {
			title: newFormat("common.register_time"),
			dataIndex: "createdAt",
			key: "createdAt",
			align: "center",
			render: (text: string) => text || "-"
		},

		// table 4
		proxyRebateDetail_memberName: {
			title: newFormat("common.member_number"),
			dataIndex: "memberName",
			key: "memberName",
			align: "center",
			render: (text: string) => text || "-"
		},
		proxyRebateDetail_payoutStatus1: {
			title: newFormat("funds.fund_audit.return_water_status"),
			dataIndex: "payoutStatus",
			key: "payoutStatus",
			align: "center",
			render: (status: number) => bounsPayoutStatusMap[status] || "-"
		},
		proxyRebateDetail_personRebateAmount1: {
			title: newFormat("funds.fund_audit.person_return_water"),
			dataIndex: "personRebateAmount",
			key: "personRebateAmount",
			align: "center",
			render: (amount: number, record: any) => handleNumber(record.currency, amount + "")
		}
	}
}

export default ProxyRebateDetailColumns
